<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %>
<%--
  Created by IntelliJ IDEA.
  User: 113
  Date: 2020/10/16
  Time: 15:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%

//加载数据库驱动

    Class.forName("com.mysql.jdbc.Driver");

    //建立连接
    String url ="jdbc:mysql://localhost:3306/book";
    Connection connection = DriverManager.getConnection(url,"root","root");

    //sql语句模板
    String sql = "delete from user where id = ?";
    //创建preparedStatement对象
    PreparedStatement ps =connection.prepareStatement(sql);

    int id = Integer.parseInt(request.getParameter("id"));
    ps.setInt(1,id);
    int count =ps.executeUpdate();

    if(count > 0){
        out.print("删除成功");
    }else{
        out.print("删除失败");
    }
%>


<html>
<head>
    <title>Title</title>
</head>
<body>

</body>
</html>
